﻿<navigation:Page x:Class="LogViewApp.Views.LogView" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"
           xmlns:controls ="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
            xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
           xmlns:windows="clr-namespace:System.Windows;assembly=System.Windows.Controls"
           d:DesignWidth="640" d:DesignHeight="480"
           Style="{StaticResource PageStyle}"
           Title="LogView Page" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
           xmlns:my="clr-namespace:LogViewApp.ViewModel">
    <sdk:Page.Resources>
        <CollectionViewSource x:Key="logViewModelViewSource" d:DesignSource="{d:DesignInstance my:LogViewModel, CreateList=True}" />
        <CollectionViewSource x:Key="logViewModellogItemsViewSource" Source="{Binding Path=logItems, Source={StaticResource logViewModelViewSource}}" />

    </sdk:Page.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="60*" />
            <ColumnDefinition Width="40*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="70*" />
            <RowDefinition Height="30*" />
        </Grid.RowDefinitions>
        <controls:GridSplitter Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Left" Background="Silver" Width="3" />
        <controls:GridSplitter Grid.Row="1" Grid.ColumnSpan="2" VerticalAlignment="top" HorizontalAlignment="Stretch" Height="3" Background="Silver"/>

        <Grid Margin="5">
            <Grid.RowDefinitions>
                <RowDefinition Height="30"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Border BorderBrush="DarkGreen" BorderThickness="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0" Background="Green">
                <TextBlock Grid.Row="0" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" >Log List</TextBlock>
            </Border>

            <sdk:DataGrid Grid.Row="1" AutoGenerateColumns="False" Name="logItemsDataGrid" RowDetailsVisibilityMode="VisibleWhenSelected" 
                          ItemsSource="{Binding logItemsShowInGrid}" SelectionChanged="logItemsDataGrid_SelectionChanged">
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTextColumn Binding="{Binding Path=Sender}" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" Header="Sender" IsReadOnly="True" />
                    <sdk:DataGridTextColumn Binding="{Binding Path=Level}" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" Header="Level" IsReadOnly="True" />
                    <sdk:DataGridTextColumn CanUserReorder="True" CanUserResize="True" CanUserSort="True" Width="Auto" Binding="{Binding Path=Message}" Header="Message" IsReadOnly="True" />
                    <sdk:DataGridTextColumn Binding="{Binding Path=Time}" CanUserReorder="True" CanUserResize="True" CanUserSort="True" Header="Time" IsReadOnly="True" Width="Auto" />
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>
        </Grid>
        <Grid Grid.Column="1" Grid.Row="0" Margin="5"  Name="FilterGrid">
            <Grid.RowDefinitions>
                <RowDefinition Height="30"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Border BorderBrush="DarkGreen" BorderThickness="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0" Background="Green">
                <TextBlock Grid.Row="0" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" >Filters</TextBlock>
            </Border>
            <Grid Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center">
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition Height="35"/>
                    <RowDefinition Height="35"/>
                    <RowDefinition Height="35"/>
                    <RowDefinition Height="35"/>
                    <RowDefinition/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="180"/>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition />
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Button Grid.Row="6" Grid.Column="1" Content="Update" Width="50" Height="20" Command="{Binding FilterUpdateCmd}" />
                <Button Grid.Row="6" Grid.Column="0" Content="Upload" Width="50" Height="20" Command="{Binding FilterUploadCmd}" />
                <TextBlock Grid.Row="1" Margin="5">Log Contains Keyword:</TextBlock>
                <TextBlock Grid.Row="2" Margin="5">Message Contains Keyword:</TextBlock>
                <TextBlock Grid.Row="3" Margin="5">Sender Name Contains:</TextBlock>
                <TextBlock Grid.Row="4" Margin="5">Error Level Equals to:</TextBlock>
                <TextBox Grid.Row="1" Grid.Column="1" Margin="5" Text="{Binding Path=LogKeyWordFilter, Mode=TwoWay}" KeyUp="TextBox_KeyUp"/>
                <TextBox Grid.Row="2" Grid.Column="1" Margin="5" Text="{Binding Path=MessageKeyWordFilter, Mode=TwoWay}" KeyUp="TextBox_KeyUp"/>
                <TextBox Grid.Row="3" Grid.Column="1" Margin="5" Text="{Binding Path=SenderNameFilter, Mode=TwoWay}" KeyUp="TextBox_KeyUp"/>
                <TextBox Grid.Row="4" Grid.Column="1" Margin="5" Text="{Binding Path=ErrorLevelFilter, Mode=TwoWay}" KeyUp="TextBox_KeyUp"/>
            </Grid>

        </Grid>
        <Grid Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" Margin="5" Name="XmlViewGrid">
            <Grid.RowDefinitions>
                <RowDefinition Height="30"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Border BorderBrush="DarkGreen" BorderThickness="3" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Grid.Row="0" Background="Green">
                <TextBlock Grid.Row="0" Foreground="White" HorizontalAlignment="Center" VerticalAlignment="Center" >XML View</TextBlock>
            </Border>
            <controls:TreeView  x:Name="xmlTree" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            </controls:TreeView>

        </Grid>
    </Grid>
</navigation:Page>
